#include "tracking.h"

vector<int> nms_aggressive(dres dres_in, vector<int> inds, double thr_nms){
	vector<int> inds_out;
	int n = dres_in.nBox;
	
	for(int i = 0; i < inds.size(); i++){
		int f1 = inds[i];
		
		int *first, *last;
		first = lower_bound(&dres_in.fr[0], &dres_in.fr[n], dres_in.fr[f1]);
		last = upper_bound(&dres_in.fr[0], &dres_in.fr[n], dres_in.fr[f1]);
		int *f2 = new int[last - first];
		for(int *j=first; j<last; j++){
			f2[j - first] = j-dres_in.fr;
		}

		ores o = calc_overlap(dres_in, f1, dres_in, f2, last - first);

		for(int j = 0; j < o.size; j++){
			if((o.ov[j] > thr_nms) || (o.ov_n1[j] > 0.9)){
				inds_out.push_back(f2[j]);
			}
		}
		delete(f2);
	}
	
	return inds_out;
}